package com.chengjue.transaction.converter;

import lombok.extern.slf4j.Slf4j;
import org.springframework.core.convert.converter.Converter;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 描述:
 * 时间转换
 * j
 *
 * @author Kipeng Huang
 * @create 2018-02-27 下午3:36
 */
@Slf4j
public class DateConverter implements Converter<String, Date> {
	private DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");

	@Override
	public Date convert(String s) {
		log.info("s:{}", s);
		if ("".equals(s) || s == null) {
			return null;
		}
		try {
			return dateFormat.parse(s);
		} catch (ParseException e) {
			e.printStackTrace();
		}

		return null;
	}
}
